{layout name="public/layout" /}

		{include file='yxnavbar'}

<link rel="stylesheet" href="{$_G['URL']['APP_CSS']}back.css">
<script type="text/javascript" src="/resource/js/underscore.min.js"></script>
<link rel="stylesheet" href="/resource/css/bootstrap-switch.min.css">
<script type="text/javascript" src="/resource/js/bootstrap-switch.min.js"></script>

	<style type="text/css">
	.order-detail-info>div{margin-bottom:10px; padding-left:15px;}
	.page-trade-order h4{font-size:14px; font-weight:700;}
	.page-trade-order .form-group{margin-bottom:0;}
	.page-trade-order .form-group .control-label{font-weight:normal; color:#999;}
	.page-trade-order .order-infos{border-right:1px solid #ddd;}
	.page-trade-order .parting-line{height:1px;border-top:1px dashed #e5e5e5; margin:3px 0;}
	.page-trade-order .order-state{padding-left:40px; position:relative; margin:20px 0 40px;}
	.page-trade-order .order-state>span{color:#07d; position:absolute; left:0; top:5px; font-size:25px; display:inline-block; width:30px; height:30px; border:1px solid #07d; border-radius:30px; text-align:center; line-height:30px;}
	#close-order ul li{padding:5px 15px; cursor:pointer;}
	#close-order ul li:hover{background:#eee;}
	.fix a.js-order-edit-address{display:none; color:red;}
	.fix:hover a.js-order-edit-address{display:inline;}
	.page-trade-order .col-sm-9{word-break: break-word; overflow:hidden;}
	.table-log>tbody>tr>td{border-top:none;}
</style>
<script type="text/javascript">
function submitForm(){
    var form = document.getElementById("myform");
    form.submit();
}
function searchForm(){
    var txt = document.getElementById("searchtuan").value;
    if (txt.length<1) {
    	alert("请输入团长的姓名或手机号");
    }else{ 
		$.ajax({
			type: 'POST',
			dataType : "json",
			url:'{php echo createWebUrl($do,array('op' => 'searchtuan','themeid'=>$themeid));}',
			data: {txt:txt},
			success: function(data) {
			data = data.message;
			 if(data.errcode == 0){
			 	alert(data.msg);
			 }else if(data.errcode == 2 || data.errcode == 1){
		    	var select = document.getElementById("tuanid");
			 	select.options.length = 0;
			 	$.each(data.tuanlist, function (n, value) {
	                $optiontxt = value.username +'【'+ value.mobile+'】已有'+value.renshu+'人';
					select.options[select.options.length] = new Option($optiontxt,value.id);
	           	});
			 	if (data.errcode == 2){
			  		alert('检索到多条记录，请选择正确的团长');
			 	}
			 }
			},
			error: function() {
			}
		});

    }
}
function searchfans(){
    var txt = document.getElementById("searchfans").value;
    if (txt.length<1) {
    	alert("请输入粉丝姓名、电话或昵称");
    }else{ 
		$.ajax({
			type: 'POST',
			dataType : "json",
			url:'{php echo createWebUrl($do,array('op' => 'searchfans','themeid'=>$themeid));}',
			data: {txt:txt},
			success: function(data) {
			data = data.message;
			 if(data.errcode == 0){
			 	alert(data.msg);
			 }else if(data.errcode == 2 || data.errcode == 1){
		    	var select = document.getElementById("tuijianren");
			 	select.options.length = 0;
			 	$.each(data.tuanlist, function (n, value) {
	                $optiontxt = value.uid +'-'+ value.username+'-'+value.mobile+'-'+value.nickname;
					select.options[select.options.length] = new Option($optiontxt,value.uid+','+value.openid);
	           	});
			 	if (data.errcode == 2){
			  		alert('检索到多条记录，请选择正确的推荐人');
			 	}
			 }
			},
			error: function() {
			}
		});

    }
}
</script>

{if $op == 'searchlog'}
	{include file='log'}
{elseif $op == 'edit'}

<div class="clearfix">
	<form class="form-horizontal form" action="" method="post" enctype="multipart/form-data">
		<div class="panel panel-default">
			<div class="panel-heading">定单信息修改</div>
			<div class="panel-body">
				<div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">微信头像</label>
                    <div class="col-sm-8 col-xs-12">
                        <img src="{$fansinfo['avatar']}" width="38" style="bsection-radius: 3px;">
                    </div>
                </div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">微信昵称</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="nickname" readonly="true" value="{$fansinfo['nickname']}" class="form-control">
					</div>
				</div>
				<div class="form-group" id="username">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color: #ff0000">*</span>{$config['nametext']}</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="username" value="{$record['username']}" class="form-control">
						<div class="help-block">在此可以更改客户的姓名、电话</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color: #ff0000">*</span>{$config['mobiletext']}</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="mobile" value="{$record['mobile']}" class="form-control">
					</div>
				</div>

            {if $config['shopstype'] == 0 }
                {if !empty($config['shops'])}
            <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">{$config['shops']}</label>
				<div class="col-sm-9 col-xs-12">
                    {if !empty($config['options'])}
                    <select id="shoptitle" name="shoptitle" > 
                    <option value="">请选择{$config['shops']}</option>
                    {loop $config['options'] $row}
                        <option value="{$row}" {if $row==$record['option']}selected="selected"{/if}>{$row}</option>
                    {/loop}
                    </select>
                    {/if}
                </div>
			</div>
                {else}
                	<input  type="hidden" name="shoptitle" value="默认" id="shoptitle">
                {/if}
            {/if}



            <div {if empty($config['address'])}style="display: none;"{/if} class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">{$config['address']}</label>
				<div class="col-sm-9 col-xs-12">
                	<input class="form-control" placeholder="{$config['address']}必填" type="text" name="address_ordernew" value="{$record['address']}" id="address_ordernew">
            	</div>
			</div>

            {if $config['shopstype'] > 0 }
                <div {if empty($config['shops'])}style="display: none;"{/if} class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">{$config['shops']}</label>
				<div class="col-sm-9 col-xs-12">
                    	<input class="form-control" placeholder="{$config['shops']}必填" type="{php echo $config['shopstype']==2?'tel':'text';}" name="shoptitle" value="{$record['option']}" id="shoptitle">
                	</div>
			</div>
            {/if}
            {if $config['datetimetype'] > 0 }
                <div {if empty($config['datetime'])}style="display: none;"{/if} class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">{$config['datetime']}</label>
				<div class="col-sm-9 col-xs-12">
                    	<input class="form-control" placeholder="{$config['datetime']}必填" type="{php echo $config['datetimetype']==2?'tel':'text';}" name="date_ordernew" value="{$record['datetime']}" id="date_ordernew">
                	</div>
			</div>
            {else}
                <div {if empty($config['datetime'])}style="display: none;"{/if} class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" >{$config['datetime']}</label>
				<div class="col-sm-3 col-xs-3">
                    	<input class="form-control" placeholder="{$config['datetime']}" type="text" onfocus="(this.type='date')" value="{$record['datetime']}" name="date_ordernew" id="date_ordernew"/>
                	</div>
			</div>
            {/if}
            <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">所属员工</label>
                <div class="col-sm-9 col-xs-12">
                    <select id="workerid" name="workerid" > 
                    <option value="0">请选择所属员工</option>
                    {loop $wlist $row}
                        <option id="{$row['uid']}" value="{$row['uid']}" {if $record['workerid'] == $row['uid'] }selected="selected"{/if}>{if $system['ruanjian']==3}{$row['companyname']}-{/if}{$row['teamname']}-{$row['username']}</option>
                    {/loop}
                    </select>
                    <span class="help-block"></span>
                </div>
            </div>
            {if $system['tuijianren'] == '1'}
            <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">推荐人</label>
                <div class="col-sm-9 col-xs-12">

					<div class="input-group">
                    <select id="tuijianren" name="tuijianren" class="form-control"  > 
                    <option value="0">如需更改请在右侧搜索</option>
                    {loop $fanslist $row}
                        <option value="{$row['uid']},{$row['openid']}" {if $record['fromuid'] == $row['uid'] }selected="selected"{/if}>{$row['uid']}-{$row['username']}-{$row['mobile']}-{$row['nickname']}</option>
                    {/loop}
                    </select>
                    <span class="input-group-addon"></span>
	                    <input type="text" id="searchfans" name="searchfans" placeholder="请输入粉丝姓名、电话或昵称" class="form-control" >
						<span onclick="searchfans();" class="input-group-addon" id="submit" type="submit" >搜索粉丝</span>
					</div>
                    <span class="help-block">搜索：输入粉丝的姓名、电话或粉丝昵称即可搜索；支持模糊搜索，多条记录需要手工再次选择</span>
                </div>
            </div>
            {/if}
            {if $config['maxcountall']>1}
            <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">所属团</label>
				<div class="col-sm-9 col-xs-12">
					<div class="input-group">
	                    <select id="tuanid" name="tuanid" class="form-control"  > 
	                    <option value="0">如需更改请在右侧搜索</option>
	                    {loop $tuanlist $row}
	                        <option value="{$row['id']}" {if $row['id']==$record['pid']}selected="selected"{/if}>{$row['username']}【{$row['mobile']}】已有{$row['renshu']}人</option>
	                    {/loop}
	                    </select>
						{if $record['type']==0}
							<span class="input-group-addon">身份:{$tuanzhang}</span>
						{elseif $record['type']==1}
							<span class="input-group-addon">身份:团员</span>
						{elseif $record['type']==9}
							<span class="input-group-addon">身份:{$danmai}</span>
						{/if}
	                    <input type="text" id="searchtuan" name="searchtuan" placeholder="请输入团长名或手机号" class="form-control" >
						<span onclick="searchForm();" class="input-group-addon" id="submit" type="submit" >搜索团</span>
                    </div>
                    <span class="help-block">若团长更改至其它团则成为新团的团员，原来的团将由第二个付款的担任团长</span>
                    <span class="help-block">搜索：输入团长的姓名或电话即可搜索，仅限搜团长；支持模糊搜索，多条记录需要手工再次选择</span>
                </div>
			</div>
            {/if}
            {if !empty($uid) }
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">会员卡余额</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="chongzhi" value="{$fansinfo['chongzhi']}" class="form-control">
						<div class="help-block">客户在店内有充值的，可以在此进行备注，方便员工进行追踪和推销</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">备注</label>
					<div class="col-sm-9 col-xs-12">
						<textarea class="form-control" name="beizhu" rows="10">{$fansinfo['beizhu']}</textarea>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">操作日志</label>
					<div class="col-sm-9 col-xs-12">
						<div class="help-block">{$record['beizhu']}</div>
					</div>
				</div>
			{/if}
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input name="submit" id="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
			<input type="hidden" name="__token__" value="{$Request.token}" />
		</div>
	</form>
</div>
{elseif $op == 'display'}
<div class="main">
	<div class="panel panel-info">
		<div class="panel-heading" style="height: 40px;">
			<div class="col-sm-2 col-xs-2 col-md-2">筛选 共{$total}条</div>
			<div class="col-sm-7 col-xs-7 col-md-7"></div>
		</div>
		<div class="panel-body">
			<form id = "myform" action="./index.php" method="get" class="form-horizontal" role="form">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="{$_P['m']}" />
				<input type="hidden" name="do" value="{$do}" />
				<input type="hidden" name="status" value="{$status}" />
				<input type="hidden" name="type" value="{$type}" />
				<input type="hidden" name="isfinish" value="{$isfinish}" />
				<!-- <input type="hidden" name="themeid" value="{$themeid}" /> -->

				{if $system['ruanjian']!==1 && $system['softstyle']!=7 }
				<div class="form-group">
					<label class="col-xs-12 col-sm-1 col-md-1 control-label">范围</label>
					<div class="col-sm-8 col-xs-8 col-md-8">
						<div class="btn-group">
							<a href="{php echo filter_url('type:-1');}" class="btn {if $type == -1}btn-primary{else}btn-default{/if}">不限 <span style="color: #ff0000">{$gsumall}</span></a>
							<a href="{php echo filter_url('type:0');}" class="btn {if $type == 0}btn-primary{else}btn-default{/if}">{$tuanzhang} <span style="color: #ff0000">{$gsum0}</span></a>
							{if $system['softstyle']!=5}
							<a href="{php echo filter_url('type:1');}" class="btn {if $type == 1}btn-primary{else}btn-default{/if}">团员 <span style="color: #ff0000">{$gsum1}</span></a>
							{/if}
							<a href="{php echo filter_url('type:9');}" class="btn {if $type == 9}btn-primary{else}btn-default{/if}">{$danmai} <span style="color: #ff0000">{$gsum9}</span></a>
							{if $system['softstyle']!=5}
							<a href="{php echo filter_url('type:10');}" class="btn {if $type == 10}btn-primary{else}btn-default{/if}">拼团中 <span style="color: #ff0000">{$gsum10}</span></a>
							<a href="{php echo filter_url('type:11');}" class="btn {if $type == 11}btn-primary{else}btn-default{/if}">拼团成功 <span style="color: #ff0000">{$gsum11}</span></a>
							{/if}
							{if count($config['options']) + count($config['addressoptions'])<=3}
							{$options}
							{/if}
						</div>
					</div>

					{if count($themelist)>1 }
						<div class="col-sm-3 col-xs-3 col-md-3">
							 <select onchange="submitForm();" class="form-control" name="themeid">
	                   		{loop $themelist $row}
				         		<option value="{$row['id']}" {if $themeid == $row['id'] }selected="selected"{/if}>{$row['id']} - {php echo mb_substr($row['title'],0,8,'utf-8');}</option>
				       		{/loop}
				     		 </select>
			 			</div>
					{else}
						<input type="hidden" name="themeid" value="{$themeid}" /> 
					{/if}
				</div>
				{/if}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">状态</label>
					<div class="col-sm-8 col-xs-8 col-md-8">
						<div class="btn-group">
							<a href="{php echo filter_url('status:-10');}" class="btn {if $status == -10}btn-primary{else}btn-default{/if}">不限</a>
							<a href="{php echo filter_url('status:0');}" class="btn {if $status == 0}btn-primary{else}btn-default{/if}">未支付<span style="color: #ff0000">{$gsum13}</span></a>
							<a href="{php echo filter_url('status:1');}" class="btn {if $status == 1}btn-primary{else}btn-default{/if}">已支付<span style="color: #ff0000">{$gsum12}</span></a>
							<!-- <a href="{php echo filter_url('status:2');}" class="btn {if $status == 2}btn-primary{else}btn-default{/if}">已核销</a> -->
							<a href="{php echo filter_url('status:-1');}" class="btn {if $status == -1}btn-primary{else}btn-default{/if}">已退款{if $_G['isSuperAdmin']}<span style="color: #ff0000">{$refundfee}</span>{/if}</a>
							<a href="{php echo filter_url('status:-2');}" class="btn {if $status == -2}btn-primary{else}btn-default{/if}">虚拟定单<span style="color: #ff0000">{$gsum16}</span></a>
							<a href="{php echo filter_url('status:3');}" class="btn {if $status == 3}btn-primary{else}btn-default{/if}">线下定单<span style="color: #ff0000">{$gsum15}</span></a>
							{if $system['jiage']>0}
							<a href="{php echo filter_url('status:21');}" class="btn {if $status == 21}btn-primary{else}btn-default{/if}">{$config['joinname']}<span style="color: #ff0000">{$gsum21}</span></a>
							<a href="{php echo filter_url('status:22');}" class="btn {if $status == 22}btn-primary{else}btn-default{/if}">{$config['joinname2']}<span style="color: #ff0000">{$gsum22}</span></a>
							{/if}
							{if $system['jiage']>1}
							<a href="{php echo filter_url('status:23');}" class="btn {if $status == 23}btn-primary{else}btn-default{/if}">{$config['joinname3']}<span style="color: #ff0000">{$gsum23}</span></a>
							{/if}
							{if $config['maxcount']>0}
							<a href="{php echo filter_url('status:-9');}" class="btn {if $status == -9}btn-primary{else}btn-default{/if}">团长排行榜</a>
							{/if}
						</div>
					</div>
					{if $system['ruanjian']==1 || $system['softstyle']==7}
					{if count($themelist)>1 }
						<div class="col-sm-3 col-xs-3 col-md-3">
							 <select onchange="submitForm();" class="form-control" name="themeid">
	                   		{loop $themelist $row}
				         		<option value="{$row['id']}" {if $themeid == $row['id'] }selected="selected"{/if}>{$row['id']} - {php echo mb_substr($row['title'],0,8,'utf-8');}</option>
				       		{/loop}
				     		 </select>
			 			</div>
					{else}
						<input type="hidden" name="themeid" value="{$themeid}" /> 
					{/if}
					{/if}
				</div>
				{if count($config['options']) + count($config['addressoptions'])>3}
				{if count($config['options'])>0}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">{$config['shops']}</label>
					<div class="col-sm-8 col-xs-8 col-md-8">
						<div class="btn-group">

							{$options}
						</div>
					</div>
				</div>
				{/if}
				{if count($config['addressoptions'])>0}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">{$config['address']}</label>
					<div class="col-sm-8 col-xs-8 col-md-8">
						<div class="btn-group">

							{$addressoptions}
						</div>
					</div>
				</div>
				{/if}
				{/if}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">按员工</label>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						 <select class="form-control" name="workerid">
                        <option value="" >全部</option>
                   		{loop $wlist $row}
			         		<option value="{$row['uid']}" {if $workerid == $row['uid'] }selected="selected"{/if}>{if $system['ruanjian']==3}{$row['companyname']}-{/if}{$row['teamname']}-{$row['username']}</option>
			       		{/loop}
			     		 </select>
					</div>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
							<a href="{php echo createWebUrl($do, array('op'=>'searchlog','logtype'=>'修改定单'));}" class="btn {if $op == 'log'}btn-primary{else}btn-default{/if}">修改定单日志</a>
					</div>
				</div>
				<div class="form-group clearfix">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">下单时间</label>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						{php echo view_form_field_daterange('createtime', array('start'=>date('Y-m-d H:i:s',$starttime),'end'=>date('Y-m-d H:i:s',$endtime)), true);}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">关键字</label>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						<input class="form-control" name="keyword" placeholder="可输入昵称、姓名、手机、团号" type="text" value="{$_P['keyword']}">
					</div>
					<div class="col-sm-1 col-lg-1 col-md-1 col-xs-6">
						<button class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
						<input type="hidden" name="__token__" value="{$Request.token}"/>
					</div>
					{if $config['iscomm'] == 1 && $_G['isSuperAdmin']}
					<div class="col-sm-1 col-lg-1 col-md-1 col-xs-6">
						<a href="{php echo createWebUrl($do, array('op'=>'refreshall'));}" class="btn {if $op == 'log'}btn-primary{else}btn-default{/if}">批量补发</a>
					</div>
					{/if}
					<div class="col-sm-6 col-lg-6 col-md-6 col-xs-6">
						{if $total<=5000}
						<input class="btn btn-default" type="submit" name="export_submit" id="export_submit" value="导出EXCEL">
						{else}
						<input class="btn btn-default" type="submit" name="export_submit" id="export_submit" value="导出EXCEL(1-5000条)">
						{/if}
						{if $total>5000}
						<input class="btn btn-default" type="submit" name="export_submit2" id="export_submit2" value="导出(5001-10000)">
						{/if}
						{if $total>10000}
						<input class="btn btn-default" type="submit" name="export_submit3" id="export_submit3" value="导出(10001-15000)">
						{/if}
						{if $total>15000}
						<input class="btn btn-default" type="submit" name="export_submit4" id="export_submit4" value="导出(15001-20000)">
						{/if}
						{if $total>20000}
						<input class="btn btn-default" type="submit" name="export_submit5" id="export_submit5" value="导出(20001-25000)">
						{/if}
						{if $total>25000}
						<input class="btn btn-default" type="submit" name="export_submit5" id="export_submit5" value="导出(25001-30000)">
						{/if}
					</div>
				</div>
			</form>
		</div>
	</div>
		<div class="panel panel-default">
			<div class="panel-body table-responsive" style="overflow:inherit">
				<table class="table table-hover">
					<thead class="navbar-inner">
						<tr>
							<th>定单号</th>
							<th>微信</th>
							<th>用户</th>
							{if ($system['jiage']>0)}
							<th>{$config['duojiagetips']}</th>
							{/if}
							{if !empty($config['address'])}
							<th>{$config['address']}</th>
							{/if}
							{if !empty($config['shops'])}
							<th>{$config['shops']}</th>
							{/if}
							{if !empty($config['datetime'])}
							<th>{$config['datetime']}</th>
							{/if} 
                            {if $config['isicon'] > 0}
							<th>点亮数</th>
							{/if}
							{if $system['fanpai']==1}
								<th>剩余抽奖次数</th>
								<th>已抽</th>
							{/if}
							{if $system['qrlist']==1}
								<th>二维码</th>
							{/if}
							<th>金额</th>
							<th>推荐</th>
							<!-- <th>核销</th> -->
							<th>状态</th>
							{if $system['softstyle']==7 && $system['friend']==1}
								<th>{$config['friend_name']}数</th>
								<th>已用</th>
							{else}
								{if $system['ruanjian']!==1 }
								<th>团号</th>
								<th>身份</th>
								{if $system['softstyle']!=5}
								<th>团状态</th>
								{/if}
								{/if}
							{/if}
							<th>时间{if !empty($system['wxapp'])}/来自{/if}</th>
							<th style="min-width:60px">员工</th>
							<th style="width:120px; text-align:right;">操作</th>
						</tr>
					</thead>
					<tbody>
						{loop $list $row}
						<tr>
							<td><b>{php echo $row['id']+9000;}</b></td>
							<td  style="font-size: 10px;max-width: 100px;">
								<img src="{php echo tomedia($row['avatar']);}" width="28" style="bsection-radius: 3px;">
								<br>
								{$row['nickname']}
							</td>
							<td>
								{$row['username']}<br>
								{$row['mobile']}
							</td>
							{if ($system['jiage']>0)}
							<td>{$row['jiagetype']}</td>
							{/if}
							{if !empty($config['address'])}
							<td  style="font-size: 10px;max-width: 100px;">
								{$row['address']}
							</td>
							{/if}
							{if !empty($config['shops'])}
							<td  style="font-size: 10px;max-width: 100px;">
								{php echo str_replace('|','<br>',$row['option']);}
							</td>
							{/if}
							{if !empty($config['datetime'])}
							<td  style="font-size: 10px;max-width: 100px;">
								{$row['datetime']}
							</td>
							{/if}
                            {if $config['isicon'] > 0}
                            <td><span class="label label-warning">{$row['lightsum']}</span></td>
							{/if}
							{if $system['fanpai']==1}
								<td>
									<a href="{php echo createWebUrl('fanpaijihui', array('themeid'=>$themeid, 'uid' => $row['uid']));}" title="查看明细" ><span class="label label-success">{php echo $row['fanpaijihui'];}</span></a>
								</td>
								
								<td>
									<a href="{php echo createWebUrl('fanpaichoujiang', array('themeid'=>$themeid, 'uid' => $row['uid']));}" title="查看明细" ><span class="label label-success">{php echo $row['fanpaichoujiang'];}</span></a>
								</td>
							{/if}
							{if $system['qrlist']==1}
							<td  style="font-size: 10px;max-width: 100px;">
								<a href="{php echo tomedia($row['qrimg']);}" title="查看大图" target="_blank"><img src="{php echo tomedia($row['qrimg']);}" width="28" style="bsection-radius: 3px;"></a>
								
							</td>
							{/if}
							<td>
								<span class="label label-success">￥{$row['fee']}</span>
							</td>
							<td style="font-size: 10px;max-width: 100px;">
								{if empty($row['fromuid'])}
								无
								{else}
								<img src="{php echo tomedia($row['avatar2']);}" width="28" style="bsection-radius: 3px;">
								<br>
								{$row['nickname2']}
								{/if}
							</td>
							
<!-- 							<td>
							   {if $row['status']!=0}
								<input type="checkbox" name="status[]" data-id="{$row['id']}" value="{$row['status']}" class="hidden" {if intval($row['status'])==2} checked="checked" {/if}/>
							   {else}
							   <span class="label label-info">未支付</span>
							   {/if}
							</td> -->
							<td>
								{if $row['status']==0}
									<span class="label label-warning">未支付</span>
									{elseif $row['status']==1}
									<span class="label label-success">已支付</span>
									{elseif $row['status']==2}
									<span class="label label-primary">已核销</span>
									{elseif $row['status']==-1}
									<span class="label label-danger">已退款</span>
									{elseif $row['status']==-2}
									<span class="label label-danger">虚拟定单</span>
									{elseif $row['status']==3}
									<span class="label label-info">线下定单</span>
									{else}
									<span class="label label-warning">其他</span>
									{/if}
							</td>
							{if $system['softstyle']==7 && $system['friend']==1}
							
							<td>
								<a href="{php echo createWebUrl('friend', array('themeid'=>$themeid, 'uid' => $row['uid']));}" title="查看明细" ><span class="label label-success">{php echo $row['friendnum'];}</span></a>
							</td>
							
							<td>
								<a href="{php echo createWebUrl('exchange', array('themeid'=>$themeid, 'uid' => $row['uid']));}" title="查看明细" ><span class="label label-success">{php echo $row['friendshiyong'];}</span></a>
							</td>
							{else}
							{if $system['ruanjian']!==1 }
							<td>
								{if $row['type']==0}
									<a href="{php echo createWebUrl($do, array('op2' => 'scan','themeid'=>$themeid, 'id' => $row['id']));}" title="查看团成员" ><span class="label label-success">{php echo $row['id']+10000;}</span></a>
								{elseif $row['type']==1}
									<a href="{php echo createWebUrl($do, array('op2' => 'scan','themeid'=>$themeid, 'id' => $row['pid']));}" title="查看团成员" ><span class="label label-primary">{php echo $row['pid']+10000;}</span></a>
									
								{elseif $row['type']==9}
									<span class="label label-warning">0</span>
								{/if}
							</td>
							<td>
								{if $row['type']==0}
									<span class="label label-success">{$tuanzhang}</span>
								{elseif $row['type']==1}
									<span class="label label-primary">团员</span>
								{elseif $row['type']==8}
									<span class="label label-primary">补余款</span>
								{elseif $row['type']==9}
									<span class="label label-warning">{$danmai}</span>
								{/if}<br>
								{if $config['groupprice2']>0 && $row['type']!=9 }
									{if $row['renshu']==0}
										<span class="label label-warning">{$gruoptips}</span>
									{else}
										<span class="label label-warning">{$gruoptips2}</span>
									{/if}
								{/if}
							</td>
							{if $system['softstyle']!=5}
							<td>
								{if $row['type']!=9}
									{if $row['isrefund']==1}
										<span class="label label-danger">手工退款</span>
									{elseif $row['isrefund']==2}
										<span class="label label-danger">组团失败已自动退款</span>
									{elseif $row['isrefund']==3}
										<span class="label label-danger">组团失败退款失败</span>
									{elseif ($row['status']>0 || $row['status']==-2) && $row['isfinish']==1}
										<span class="label label-success">拼团成功{if $config['maxcount']>0}({$row['tuannum']}人){/if}</span>
									{elseif ($row['status']>0 || $row['status']==-2) && $row['xunifinish']==1}
										<span class="label label-danger">虚拟成团{if $config['maxcount']>0}({$row['tuannum']}人){/if}</span>
									{elseif ($row['status']>0 || $row['status']==-2)}
										<span class="label label-primary">拼团中{if $config['maxcount']>0}({$row['tuannum']}人){/if}</span>
									{/if}
								{/if}
							</td>
							{/if}
							{/if}
							{/if}
<!-- 							<td>
								{if $row['type']==0}
									<span class="label label-success">{$tuanzhang}[已召集团员{$row['tynum']}人]</span>
									<br>
									{if $row['status']==0}
										<br>
										<span class="label label-danger" style="margin-top: 3px;">需要[{if $row['num']==-1}{$config['maxcount']}{else}{$row['num']}{/if}人]</span>

									{else}
										<br>
										{if $row['isfinish']==0}
											<span class="label label-danger" style="margin-top: 3px;">需要[{if $row['num']==-1}{$config['maxcount']}{else}{$row['num']}{/if}人] 拼团中</span>
										{else}
											<span class="label label-warning"  style="margin-top: 3px;">需要[{if $row['num']==-1}{$config['maxcount']}{else}{$row['num']}{/if}人] 已完成</span>
										{/if}
									{/if}
								{elseif $row['type']==1}
									<span class="label label-primary">团员</span><br><br>
									<span class="label label-success">团号:{php echo $row['precord']['id']+10000;}</span>
								{elseif $row['type']==9}
									<span class="label label-warning">{$danmai}</span>
								{else}
								{/if}
								
							</td> -->
							<td  style="font-size: 10px;max-width: 100px;">{php echo date('Y-m-d', $row['addtime']);}<br>{php echo date('H:i:s', $row['addtime']);}{if !empty($system['wxapp'])}<br>{php echo $system['wxapp']==$row['uniacid']?'小程序':'H5链接';}{/if}</td>

							<td ><a href="{php echo createWebUrl('record',array('themeid'=>$themeid,'workerid'=>$row['workerid'],'status'=>1,'op'=>'display'));}" >{$row['workername']}<br>{$row['teamname']}<br>{php echo mb_substr($row['companyname'],0,6,'utf-8');}</a></td>
							<td style="text-align:right; overflow:visible;">
								<div class="btn-group">
									{if $row['type']==9}
									<a href="{php echo createWebUrl($do, array('op' => 'uptuanzhang','themeid'=>$themeid, 'id' => $row['id']));}" style="width: 30px" class="btn btn-success btn-sm" onclick="if(!confirm('单买改为拼团,改为后为新团长，确定吗')) return false;"  title="单买升级为拼团" data-toggle="tooltip" data-placement="top"><i class="fa fa-angle-double-up"> </i></a>
									{else}
									<a href="{php echo createWebUrl($do, array('op' => 'newtuan','themeid'=>$themeid, 'id' => $row['id']));}" style="width: 30px" class="btn btn-success btn-sm" onclick="if(!confirm('原定单保留,开一个新团此客户为团长，确定吗')) return false;"  title="开新团" data-toggle="tooltip" data-placement="top"><i class="fa fa-copy"> </i></a>
									<!-- <a href="{php echo createWebUrl($do, array('op2' => 'scan','themeid'=>$themeid, 'id' => $row['pid']));}" class="btn btn-success btn-sm"  title="查看团成员" data-toggle="tooltip" data-placement="top"><i class="fa fa-eye"> </i></a>	 -->
<!-- 									{if !empty($row['openid'])}
									<a href="{php echo createWebUrl($do, array('op' => 'up','themeid'=>$themeid, 'id' => $row['id']));}" class="btn btn-success btn-sm" onclick="if(!confirm('由团员升级为新团的团长，确定执行吗')) return false;"  title="升级为团长" data-toggle="tooltip" data-placement="top"><i class="fa fa-plus"> </i></a>
									{/if} -->
									{/if} 
									<a href="{php echo createWebUrl($do, array('op' => 'refund','themeid'=>$themeid, 'id' => $row['id']));}" style="width: 30px" class="btn btn-warning btn-sm" onclick="if(!confirm('当客户拍错或退单时可以直接退回原帐户，确定退款吗')) return false;"  title="退款" data-toggle="tooltip" data-placement="top"><i class="fa fa-chain-broken"> </i></a>	
									{if $config['iscomm'] == 1 }
									<a href="{php echo createWebUrl('commshare', array('op' => 'display','themeid'=>$themeid,'uid'=>$row['uid'],'openid'=>$row['openid']));}" class="btn btn-warning btn-sm" title="查看红包记录" data-toggle="tooltip" data-placement="top"  return false;"><i class="fa fa-list"> </i></a>
									<a href="{php echo createWebUrl($do, array('op' => 'refresh','themeid'=>$themeid, 'id' => $row['id']));}" style="width: 30px" class="btn btn-info btn-sm" onclick="if(!confirm('当上级没有收到可在这里直接补发,确定补发吗')) return false;"  title="补发红包" data-toggle="tooltip" data-placement="top"><i class="fa fa-undo"> </i></a>	

									{/if}

									{if ($row['status']>0 || $row['status']==-2) && $row['isfinish']==1}
									{elseif ($row['status']>0 || $row['status']==-2)  && $row['xunifinish']==0}
										<a href="{php echo createWebUrl($do, array('op' => 'xunifinish','themeid'=>$themeid, 'id' => $row['pid']));}" style="width: 30px" class="btn btn-info btn-sm" onclick="if(!confirm('虚拟组团成功,确定后客户无法再拉人进团,确定虚拟成团吗')) return false;"  title="虚拟成团" data-toggle="tooltip" data-placement="top"><i class="fa fa-users"> </i></a>	
									{elseif ($row['status']>0 || $row['status']==-2) && $row['xunifinish']==1}
										<a href="{php echo createWebUrl($do, array('op' => 'unxunifinish','themeid'=>$themeid, 'id' => $row['pid']));}" style="width: 30px" class="btn btn-info btn-sm" onclick="if(!confirm('取消虚拟成团,确定后客户可再拉人进团,确定取消虚拟成团吗')) return false;"  title="取消虚拟成团" data-toggle="tooltip" data-placement="top"><i class="fa fa-user-times"> </i></a>	
									{/if}

									

									<a href="{php echo createWebUrl($do, array('op' => 'edit','themeid'=>$themeid,'uid' => $row['uid'], 'id' => $row['id']));}" style="width: 30px" class="btn btn-primary btn-sm"  title="修改定单" data-toggle="tooltip" data-placement="top"><i class="fa fa-pencil-square-o"> </i></a>

                                    {if $_G['isSuperAdmin']|| $row['status']==-2 || $row['status']==3 || $row['status']==0  }
									<a href="{php echo createWebUrl($do, array('op' => 'delete','themeid'=>$themeid, 'id' => $row['id']));}" style="width: 30px" class="btn btn-danger btn-sm" onclick="if(!confirm('参团记录相关的数据将全被删除，确定删除吗')) return false;"  title="删除" data-toggle="tooltip" data-placement="top"><i class="fa fa-times"> </i></a>						
								    {/if}
                                </div>
							</td>
						</tr>
						{/loop}
					
					</tbody>
				</table>
			</div>
		</div>
		{$pager}
</div>
<script type="text/javascript">
	$(function(){
		$('.app-preview').click(function(){
			return false;
		});
		
			$(":checkbox[name='isluck[]']").bootstrapSwitch();
			$(":checkbox[name='isluck[]']").on('switchChange.bootstrapSwitch', function(e, state){
				$this = $(this);
				var id = $(this).data('id');
				var isluck = this.checked ? 1 : 0;
				$.post("{php echo createWebUrl($do, array('op' => 'isluck','themeid'=>$themeid));}", {isluck:isluck,id: id}, function(resp){
					resp = $.parseJSON(resp);
					if(resp.message.errno != 0) {
						layer.msg('操作失败, 请稍后重试');
					} else {
						layer.msg('操作成功');
					}
				});
			});
			$(":checkbox[name='status[]']").bootstrapSwitch();
			$(":checkbox[name='status[]']").on('switchChange.bootstrapSwitch', function(e, state){
				$this = $(this);
				var id = $(this).data('id');
				var status = this.checked ? 2 : 1;
				$.post("{php echo createWebUrl($do, array('op' => 'status','themeid'=>$themeid));}", {status:status,id: id}, function(resp){
					resp = $.parseJSON(resp);
					if(resp.message.errno != 0) {
						layer.msg('操作失败, 请稍后重试');
					} else {
						layer.msg('操作成功');
					}
				});
			});
			
			
			
			
		});
	});
</script>
<script type="text/javascript">
// require(['util'], function(u){

// 	$('#selectall').click(function(){
// 		$('#form-order :checkbox').prop('checked', $(this).prop('checked'));
// 	});

// 	$('.btn-order').click(function(){
// 		if($('#form-order :checkbox:checked').length == 0) {
// 			u.message('请选择定单', '', 'error');
// 			return false;
// 		}
// 		if(!confirm('确定修改定单的状态吗')) {
// 			return false;
// 		}
// 		$('#form-order #status').val($(this).data('id'));
// 		$('#form-order #type').val($(this).data('type'));
// 		$('#form-order').submit();
// 		return false;
// 	});

// 	$('.btn-cancel').click(function(e){
// 		var pay = $(this).data('pay');
// 		var pay_type = $(this).data('pay-type');
// 		var tip = '确定取消定单吗';
// 		if(pay == 1) {
// 			if(pay_type == 'cash') {
// 				var tip = '该定单为现金支付, 取消定单需要商家自己处理退款, 确定取消定单吗';
// 			} else if(pay_type != 'delivery') {
// 				var tip = '该定单为线上支付, 取消定单将发起退款流程, 确定取消定单吗';
// 			}
// 		}
// 		if(!confirm(tip)) {
// 			e.preventDefault();
// 		}
// 		return true;
// 	});


// });
</script>
{elseif $op == 'show'}
<form class="form-horizontal" role="form">
	<div class="page-trade-order">
		<div class="order-list">
			<div class="freight-content">
				<div class="freight-template-item panel panel-default">
					<div class="panel-body clearfix">
						<div class="col-xs-12 col-sm-6 order-infos">
							<h4>定单信息</h4>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">定单编号</label>
								<div class="col-md-9 form-control-static">
									{$order['ordersn']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">所属类型</label>
								<div class="col-md-9 form-control-static">
									{if $order['ordertype']=='special'}
									<span class="label label-info">专题</span>
							{elseif $order['ordertype']=='activity'}
									<span class="label label-primary">活动</span>
							{elseif $order['ordertype']=='buy'}
									<span class="label label-primary">商品</span>
							{elseif $order['ordertype']=='scanpay'}
									<span class="label label-primary">扫码支付</span>
									{else}
									<span class="label label-warning">其他</span>
									{/if}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">客户信息</label>
								<div class="col-md-9 form-control-static">
									{$order['username']} {$order['mobile']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">下单时间</label>
								<div class="col-md-9 form-control-static">
									{php echo date('Y-m-d H:i:s', $order['addtime']);}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">定单状态</label>
								<div class="col-md-9 form-control-static">
									{if $order['status']=='0'}
									<span class="label label-warning">未支付</span>
								{elseif $order['status']=='1'}
									<span class="label label-success">未核销</span>
								{elseif $order['status']=='2'}
									<span class="label label-primary">已核销</span>
								{elseif $order['status']=='-1'}
									<span class="label label-primary">已退款</span>
								{else}
									<span class="label label-warning">其他</span>
								{/if}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">定单价格</label>
								<div class="col-md-9 form-control-static">
									￥ {$order['orderfee']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">实际支付</label>
								<div class="col-md-9 form-control-static">
									￥ {$order['realfee']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">卡券使用</label>
								<div class="col-md-9 form-control-static">
									{if $row['usecard']==0}
							<span class="label label-info">未使用</span>
							{else}
							<span class="label label-primary">已使用</span>
							{/if}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">付款方式</label>
								<div class="col-md-9 form-control-static">
									{if !$order['paystate']}
										<span class="label label-danger">未支付</span>
									{else}
										{if $order['type']=='credit'}
											<span class="label label-info">余额支付</span>
											{elseif $order['type']=='wechat'}
											<span class="label label-success">微信支付</span>
											{elseif $order['type']=='delivery'}
											<span class="label label-primary">货到付款</span>
											{else}
											<span class="label label-warning">其他方式</span>
											{/if}
									{/if}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">付款时间</label>
								<div class="col-md-9 form-control-static">
									{php echo date('Y-m-d H:i:s', $order['paytime']);}
								</div>
							</div>
							
							
						</div>
{if $order['ordertype']=='special'}
						<div class="col-xs-12 col-sm-6">
							<h4>所属专题</h4>
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">专题名称</label>
								<div class="col-md-9 form-control-static">
									{$goods['special']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">购买商品</label>
								<div class="col-md-9 form-control-static">
									{$goods['title']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">商品数量</label>
								<div class="col-md-9 form-control-static">
									{$goods['count']}
								</div>
							</div>
														<div class="form-group clearfix">
								<label class="col-md-3 control-label">收货人</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzusername']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">电话</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzmobile']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">地址</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzaddress']}
								</div>
							</div>
						</div>
{elseif $order['ordertype']=='activity'}
						<div class="col-xs-12 col-sm-6">
							<h4>所属活动</h4>
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">活动名称</label>
								<div class="col-md-9 form-control-static">
									{$activity['title']}
								</div>
							</div>
							{loop $liaisons $item}
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">报名人信息</label>
								<div class="col-md-9 form-control-static">
									{$item['username']} {$item['mobile']} 
								</div>
							</div>
							
							{/loop}
						</div>
{elseif $order['ordertype']=='buy'}
						<div class="col-xs-12 col-sm-6">
							<h4>商品信息</h4>
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">商品名称</label>
								<div class="col-md-9 form-control-static">
									{$goods['title']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">商品数量</label>
								<div class="col-md-9 form-control-static">
									{$goods['count']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">收货人</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzusername']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">电话</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzmobile']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">地址</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzaddress']}
								</div>
							</div>
						</div>
{elseif $order['ordertype']=='scanpay'}
						<div class="col-xs-12 col-sm-6">
							<h4>商户信息</h4>
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">商户名称</label>
								<div class="col-md-9 form-control-static">
									{$shop['title']}
								</div>
							</div>
						</div>
{else}
其他
{/if}

						
						
						
						
					</div>
				</div>
			</div>
		</div>
	</div>

</form>
{/if}
